<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目成员/外派人员列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>进场时间：</label>
                                <input type="text" class="time-input" placeholder="请选择进场时间" name="onboardTime"/>
                            </li>
                            <li>
                                <label>进场状态：</label>
                                <select name="onboardStatus" th:with="type=${@dict.getType('project_onboard_status')}">
                                    <option value="all">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue} == 'onboard'"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="project:project.member:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('project:project:member:edit')}]];
        var removeFlag = [[${@permission.hasPermi('project:project:member:remove')}]];
        var onboardStatusDatas = [[${@dict.getType('project_onboard_status')}]];
        var prefix = ctx + "erp/project/" +[[${project.getId()}]] + "/member";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目成员/外派人员",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'profile.name',
                    title: '员工姓名'
                },
                {
                    field: 'staffingSetting.quotationMonth',
                    title: '折合月单价(元)'
                },
                {
                    field: 'postName',
                    title: '岗位'
                },
                {
                    field: 'onboardTime',
                    title: '进场时间'
                },
                {
                    field: 'departTime',
                    title: '离场时间'
                },
                {
                    field: 'description',
                    title: '备注'
                },
                {
                    field: 'onboardStatus',
                    title: '进场状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(onboardStatusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var departUrl = prefix + "/depart/" + row.id;
                        var settingUrl =  "/staffing/setting/modal/person/" + row.id;
                        if (row.project.projectType == "staffing"){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.modal.open(\'' + row.profile.name + ' 外派属性设置\',\''+ settingUrl+ '\',\'700\',\'700\')"><i class="fa fa-cogs"></i>&nbsp;外派属性</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>&nbsp;编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.modal.open(\'员工退场\',\'' + departUrl + '\')"><i class="fa fa-level-up"></i>&nbsp;退场</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>